<?php

/**
 * Upravnik filter form.
 *
 * @package    dnevnik
 * @subpackage filter
 * @author     Your name here
 * @version    SVN: $Id: sfPropelFormFilterTemplate.php 11675 2008-09-19 15:21:38Z fabien $
 */
class UpravnikFormFilter extends BaseUpravnikFormFilter
{
  public function configure()
  {
     $this->widgetSchema['username'] = new sfWidgetFormFilterInput();
     $this->validatorSchema['username'] = new sfValidatorPass(array('required' => false));
     $this->widgetSchema['prezime'] = new sfWidgetFormFilterInput();
     $this->validatorSchema['prezime'] = new sfValidatorPass(array('required' => false));
     $this->widgetSchema['ime'] = new sfWidgetFormFilterInput();
     $this->validatorSchema['ime'] = new sfValidatorPass(array('required' => false));
  }

  public function getFields()
  {
    return array_merge(array(
        'username' => 'Username',
        'prezime' => 'Prezime',
        'ime' => 'Ime',
      ), parent::getFields()
    );
  }

  protected function addUsernameColumnCriteria(Criteria $criteria, $field, $values)
  {
      $criteria->addJoin(UpravnikPeer::ID , ProfilPeer::ID);
      $criteria->add(ProfilPeer::USERNAME, '%'.$values['text'].'%', Criteria::LIKE);
  }

  protected function addPrezimeColumnCriteria(Criteria $criteria, $field, $values)
  {
      $criteria->addJoin(UpravnikPeer::ID , ProfilPeer::ID);
      $criteria->add(ProfilPeer::PREZIME, '%'.$values['text'].'%', Criteria::LIKE);
  }

  protected function addImeColumnCriteria(Criteria $criteria, $field, $values)
  {
      $criteria->addJoin(UpravnikPeer::ID , ProfilPeer::ID);
      $criteria->add(ProfilPeer::IME, '%'.$values['text'].'%', Criteria::LIKE);
  }

}
